/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rafkind.crawl.generator.monsters;

import java.util.HashMap;
import java.util.Map;

/**
 * Monster battle group
 *
 * @author drafkind
 */
public class Group {
  private Map<MonsterType, Integer> monsters;

  public Group() {
    monsters = new HashMap<MonsterType, Integer>();
  }

  public Map<MonsterType, Integer> getMonsters() {
    return monsters;
  }

  public boolean contains(MonsterType mt) {
    return monsters.containsKey(mt);
  }

  public void add(int count, MonsterType mt) {
    monsters.put(mt, count);
  }

  public void print() {
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (Map.Entry<MonsterType, Integer> ev : monsters.entrySet()) {
      if (first) {
        sb.append("[");
        first = false;
      } else {
        sb.append(", ");
      }
      sb.append(ev.getValue() + " x " + ev.getKey().getName());
      sb.append("<A: " + ev.getKey().getAtt() + ",D: " + ev.getKey().getDef() + ", G: " + ev.getKey().getGold() + ", X: " + ev.getKey().getXP());
      if (ev.getKey().getPersonality() != null) {
        sb.append(", P: " + ev.getKey().getPersonality());
      }
      sb.append(">");
    }
    sb.append("]");

    System.out.println("    " + sb.toString());
  }
}